<?php


namespace App\Admin\Controller\App;


use App\Admin\Controller\AdminBaseController;
use App\Admin\Requests\App\ProjectType\ProjectTypeCreateRequest;
use App\Admin\Requests\App\ProjectType\ProjectTypeUpdateAuditItemListRequest;
use App\Admin\Requests\App\ProjectType\ProjectTypeUpdateDomainRequest;
use App\Admin\Requests\App\ProjectType\ProjectTypeUpdateRequest;
use App\Admin\Services\App\ProjectTypeService;

class ProjectTypeController extends AdminBaseController {
    public $exceptActionList = ['listForSelect'];
    private $_service;

    public function __construct(ProjectTypeService $service) {
        $this->_service = $service;
    }

    /**
     * 应用项目类型列表
     *
     * @return mixed
     */
    public function page() {
        return $this->success($this->_service->page());
    }

    /**
     * 新建应用项目类型
     *
     * @param ProjectTypeCreateRequest $request
     * @return mixed
     */
    public function store(ProjectTypeCreateRequest $request) {
        return $this->success($this->_service->store($request));
    }

    /**
     * 删除指定id的应用项目类型
     *
     * @param $id
     * @return mixed
     * @throws \App\Admin\Exceptions\App\ProjectType\ProjectTypeException
     */
    public function delete($id) {
        return $this->success($this->_service->delete($id));
    }

    /**
     * 更新指定id的应用项目类型
     *
     * @param $id
     * @param ProjectTypeUpdateRequest $request
     * @return mixed
     * @throws \Exception
     */
    public function update($id, ProjectTypeUpdateRequest $request) {
        return $this->success($this->_service->update($id, $request));
    }

    /**
     * 获取可用的应用项目类型下拉列表
     *
     * @return mixed
     */
    public function listForSelect() {
        return $this->success($this->_service->listForSelect());
    }

    /**
     * 修改应用项目类型服务器域名及业务域名
     *
     * @param $id
     * @param ProjectTypeUpdateDomainRequest $request
     * @return mixed
     * @throws \Exception
     */
    public function updateDomain($id, ProjectTypeUpdateDomainRequest $request) {
        return $this->success($this->_service->update($id, $request));
    }

    /**
     * 修改审核项列表
     *
     * @param $id
     * @param ProjectTypeUpdateAuditItemListRequest $request
     * @return mixed
     * @throws \Exception
     */
    public function updateAuditItemList($id, ProjectTypeUpdateAuditItemListRequest $request) {
        return $this->success($this->_service->update($id, $request));
    }
}